using Patterns.Interfaces;

namespace PatternTests.Tools
{
    public class Sum : IAggregate<int, int>
    {
        #region Fields
        private int _sum;
        #endregion

        #region methods
        public void Initialize() { _sum = 0; }

        public void Accumulate(int accumulate) { _sum += accumulate; }

        public void Accumulate(object accumulate) { Accumulate((int)accumulate); }

        object IAggregate.Terminate() { return Terminate(); }

        public int Terminate() { return _sum; }
        #endregion
    }

    public class Count : IAggregate<object, int>
    {
        #region Fields
        private int _count;
        #endregion

        #region methods
        public void Initialize() { _count = 0; }

        public void Accumulate(object accumulate) { _count++; }

        object IAggregate.Terminate() { return Terminate(); }

        public int Terminate() { return _count; }
        #endregion
    }
}